import java.util.*;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n=in.nextInt();
        long[] a=new long[n];
        for(int i=0;i<n;i++){
            a[i]=in.nextLong();
        }
        Arrays.sort(a);
        long max=a[n-1];
        boolean flg=true;
        for(int i=0;i<n-1;i++){
            while(a[i]<max){
                a[i]*=2;
            }
            if(a[i]!=max){
                flg=false;
                break;
            }
        }
        if(flg){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
    }
    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
        String a=in.next();
        String b=in.next();
        char[] ch1=a.toCharArray();
        char[] ch2=b.toCharArray();
        int n1=ch1.length;
        int n2=ch2.length;
        int min=n2;
        for(int i=0;i<=n2-n1;i++){
            int tmp=0;
            for(int j=0;j<n1;j++){
                if(ch1[j]!=ch2[i+j]){
                    tmp++;
                }
            }
            min=Math.min(tmp,min);
        }
        System.out.println(min);
    }
}